package com.starryx.blog.dao;

import com.starryx.blog.po.Blog;
import com.starryx.blog.po.Tag;
import com.starryx.blog.vo.BlogQuery;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;


import java.util.List;

@Repository
public interface BlogMapper {    // 特殊查询类，类似于实现动态sql查询
    Blog findOneById(@Param("id") Long id);

    List<Blog> findAll();

    List<Blog> findAllByBlogQuery(BlogQuery blogQuery);

    List<Blog> findAllByTagId(@Param("tag_id") Long tagId);

    List<Blog> findTop();

    List<Blog> findByQuery(@Param("query") String query);

    List<String> findGroupYear();

    List<Blog> findByYear(@Param("year") String year);

    List<Blog> findAllByTypeId(@Param("type_id") Long id);

    List<Blog> findAllByUserId(@Param("user_id") Long id);

    Long count();

    int save(Blog blog);

    int saveTags(Blog blog);

    int update(Blog blog);

    void delete(@Param("id") Long id);

    void deleteTags(@Param("id") Long id);
}
